	/*
	 * Copyright (c) 2011 Srdjan VESIC.
	 * Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; GNU Free Documentation License is available at
	http://www.gnu.org/copyleft/fdl.html 
	 */
	package map;

	import java.awt.Point;
	import java.util.ArrayList;
	import java.util.Collection;
import java.util.Iterator;
import java.util.List;

import core.dijkstra.RoutesMap;


	/**
	 * Stores data of an airport
	 * 
	 * @author NOMS DES MEMBRES DU GROUPE
	 * @version 1.0
	 */
	public class Airport implements Comparable<Airport>{
		/** Coordinates */
		private Point coord;
		/** Airport name (3 letters) */
		private String code;

		/**
 *
 */

		/*
		 * (non-javadoc)
		 */

		/**
 *
 */
		private Collection<Airport> voisins;

		/**
		 * Getter of the property <tt>voisins</tt>
		 * 
		 * @return Returns the voisins.
		 * 
		 */

		public Collection<Airport> getVoisins() {
			return voisins;
		}

		/**
		 * Returns an iterator over the elements in this collection.
		 * 
		 * @return an <tt>Iterator</tt> over the elements in this collection
		 * @see java.util.Collection#iterator()
		 * 
		 */
		public Iterator<Airport> voisinsIterator() {
			return voisins.iterator();
		}
		
		/**
		 * Returns <tt>true</tt> if this collection contains no elements.
		 * 
		 * @return <tt>true</tt> if this collection contains no elements
		 * @see java.util.Collection#isEmpty()
		 * 
		 */
		public boolean isVoisinsEmpty() {
			return voisins.isEmpty();
		}

		/**
		 * Returns <tt>true</tt> if this collection contains the specified
		 * element.
		 * 
		 * @param element
		 *            whose presence in this collection is to be tested.
		 * @see java.util.Collection#contains(Object)
		 * 
		 */
		public boolean containsVoisins(Airport voisins) {
			return this.voisins.contains(voisins);
		}

		/**
		 * Returns <tt>true</tt> if this collection contains all of the elements
		 * in the specified collection.
		 * 
		 * @param elements
		 *            collection to be checked for containment in this
		 *            collection.
		 * @see java.util.Collection#containsAll(Collection)
		 * 
		 */
		public boolean containsAllVoisins(Collection<Airport> voisins) {
			return this.voisins.containsAll(voisins);
		}

		/**
		 * Returns the number of elements in this collection.
		 * 
		 * @return the number of elements in this collection
		 * @see java.util.Collection#size()
		 * 
		 */
		public int voisinsSize() {
			return voisins.size();
		}

		/**
		 * Returns all elements of this collection in an array.
		 * 
		 * @return an array containing all of the elements in this collection
		 * @see java.util.Collection#toArray()
		 * 
		 */
		public Airport[] voisinsToArray() {
			return voisins.toArray(new Airport[voisins.size()]);
		}

		/**
		 * Setter of the property <tt>voisins</tt>
		 * 
		 * @param voisins
		 *            the voisins to set.
		 * 
		 */
		public void setVoisins(Collection<Airport> voisins) {
			this.voisins = voisins;
		}

		/**
		 * Ensures that this collection contains the specified element (optional
		 * operation).
		 * 
		 * @param element
		 *            whose presence in this collection is to be ensured.
		 * @see java.util.Collection#add(Object)
		 * 
		 */
		public boolean addVoisins(Airport voisins) {
			return this.voisins.add(voisins);
		}

		/**
		 * Removes a single instance of the specified element from this
		 * collection, if it is present (optional operation).
		 * 
		 * @param element
		 *            to be removed from this collection, if present.
		 * @see java.util.Collection#add(Object)
		 * 
		 */
		public boolean removeVoisins(Airport voisins) {
			return this.voisins.remove(voisins);
		}

		/**
		 * Removes all of the elements from this collection (optional
		 * operation).
		 * 
		 * @see java.util.Collection#clear()
		 * 
		 */
		public void clearVoisins() {
			this.voisins.clear();
		}

		public Airport(Point coord, String code) {
			this.coord = coord;
			this.code = code;
			voisins = new ArrayList<Airport>();
		}

		/**
		 * Sets coordinates
		 * 
		 * @param coord
		 *            coordinates to be set
		 */
		public void setCoord(Point coord) {
			this.coord = coord;
		}

		/**
		 * Gets coordinates
		 * 
		 * @return Point being the coordinates
		 */
		public Point getCoord() {
			return coord;
		}

		/**
		 * Sets airport name
		 * 
		 * @param code
		 *            name to be set
		 */
		public void setCode(String code) {
			this.code = code;
		}

		/**
		 * Gets airport name
		 * 
		 * @return name of the airport
		 */
		public String getCode() {
			return code;
		}
		
		public String toString() {
			return code;
		}

		@Override
		public int compareTo(Airport o) {
			return code.compareTo(o.code);
		}
		
		public int distance(Airport b) {
			return (int)this.coord.distance(b.coord);
		}

	}

